Repository navigation
fix(abstractions): improve parameter collection sanitization and ISO duration validation - #883
Merged
Vincent Biret (baywet) merged 6 commits intoNov 9, 2026
Conversation
…duration parser Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…equirements Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…ization Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…ements in query parameters Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…l entries in parameters Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
|
Vincent Biret (baywet)
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Overview
As requested in #867 (comment), this pull request extracts the parameter collection sanitization and ISO duration component validation changes from PR #867 into a dedicated PR:
Parameter Collection Sanitization and Null Filtering (
request_information.py):RequestInformation._get_sanitized_value(), collections containingNoneelements (e.g.[None, 'active']or all-Nonelists[None, None]) previously passedNoneelements directly toStdUriTemplate.expand(), triggeringValueError: Illegal class passed as substitution: None.all(isinstance(x, Enum) for x in value). When an enum list contained a leadingNone(e.g.[None, Status.Active]), the check evaluated toFalseand bypassed comma-joining, producing an unnormalized list of scalar strings rather than a comma-joined enum string._get_sanitized_value()to filterNoneelements and inspect surviving non-null elements, ensuring order-independent enum normalization regardless of leading/trailing/interleavedNoneentries, and returning an empty collection when all elements areNone.Component Validation in ISO 8601 Duration Parser (
date_utils.py):parse_timedelta_from_iso_format()previously evaluated date/time group values (years or months or daysandhours or minutes or seconds) numerically rather than checking presence of match groups. As a result, duration strings without components (such as"P"or"PT") and weeks combined with zero-valued time designators (such as"P1WT0S") were incorrectly parsed astimedelta(0)or allowed without error.bool(m.group(...))and ensured durations lacking any date, time, or week components raise aValueError.Changes
packages/abstractions/kiota_abstractions/date_utils.py:ValueErroron empty strings like"P"or"PT".packages/abstractions/kiota_abstractions/request_information.py:Noneelements in collection sanitization to prevent substitution errors inStdUriTemplate.packages/abstractions/tests/test_date_utils.py:"P","PT","P1WT0S", and zero-duration ISO strings.packages/abstractions/tests/test_request_information.py:Noneelements and enum collections withNoneentries in query/path parameters.Verification
pytest: 226 passed.mypy kiota_abstractions: clean (no issues in 48 source files).